import sys
import getopt
from network_creation import NaiveNetworkSimulation


def usage():
    print ('-------------------------------')
    print("Naive simulation toy model")
    print ('-------------------------------')    
    print("Usage:")
    print('naive_simulation -d number_of_documents_to_generate -t number_of_tests_to_perform')
    print('-v for verbosity is optional')

def main(argv = None):
    
    if argv is None:
        argv = sys.argv

    try:
        opts, args = getopt.getopt(sys.argv[1:],'d:t:v')
        if (len(opts) < 2):
        	raise Exception
    except getopt.GetoptError, err:
        usage()
        print str(err)
        return -1
    except Exception, err:
        usage()
        print 'all options are required'
        return -2

    verbose = False
    #options processing
    
    try:
        for opt in opts:	
            if opt[0] == '-d':
            	documents = int(opt[1])			
            if opt[0] == '-t':	
            	tests = int(opt[1])
            if opt[0] == '-v':	
            	verbose = True
    except Exception, e:
        usage()
        print 'Error: options -d and -t should be integers'
        return -3

    simulation = NaiveNetworkSimulation(documents, tests, verbose)
    simulation.perform_simulation()

if __name__ == "__main__":
    
	result = main(sys.argv)
	sys.exit(result)
